//
//  EPMGoodsTableViewCell.m
//  myXianfeng
//
//  Created by 马继鵬 on 17/5/4.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "EPMGoodsTableViewCell.h"

@interface EPMGoodsTableViewCell()

@property (weak, nonatomic) IBOutlet UIButton *btnSelected;
@property (weak, nonatomic) IBOutlet UIImageView *imgIcon;

@property (weak, nonatomic) IBOutlet UILabel *labGoodName;
@property (weak, nonatomic) IBOutlet UILabel *labPrice;
@property (weak, nonatomic) IBOutlet UILabel *labCount;
@property (weak, nonatomic) IBOutlet UIButton *btnDecrease;

@end
@implementation EPMGoodsTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
   
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)actionGoodCountChange:(UIButton *)sender {
    if (sender.tag == 1){
        [[NSNotificationCenter defaultCenter] postNotificationName:EPMMarketDecreaseGoodNotification object:nil userInfo:@{
                                                        KDecreaseGoodsModel: self.model
                                                                         }];
    }else if (sender.tag == 2){
        [[NSNotificationCenter defaultCenter] postNotificationName:EPMHomeIncreaseGoodsNotification object:nil userInfo:@{KIncreaseGoodsModel:self.model}];
    }
}
- (IBAction)actionSelected:(id)sender {
    
}
- (IBAction)actionJumpToDetail:(id)sender {
    
}

- (void)setLabHiden:(NSInteger)num{
    self.labCount.hidden = (num == 0);
    self.btnDecrease.hidden = (num == 0);
}

- (void)setModel:(EPMGoodsModel *)model{
    _model = model;
    [self setLabHiden:model.count];
    self.labCount.text = [NSString stringWithFormat:@"%zd",model.count];
    [self.imgIcon sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"bee"]];
    self.labGoodName.text = model.name;
    self.labPrice.text = model.price;
    
}
@end
